{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "EgiF12Hf1Dhs"
   },
   "source": [
    "This notebook provides examples to go along with the [textbook](http://manipulation.csail.mit.edu/pick.html).  I recommend having both windows open, side-by-side!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "eeMrMI0-1Dhu"
   },
   "outputs": [],
   "source": [
    "import pydot\n",
    "from IPython.display import SVG, display\n",
    "from pydrake.all import MultibodyPlant, Parser\n",
    "from manipulation.utils import ConfigureParser"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "7q0A14bAilIX"
   },
   "source": [
    "# Inspecting the kinematic tree\n",
    "\n",
    "Here is a simple example that demonstrates how to inspect the kinematic tree stored in a `MultibodyPlant`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "ILYLouFTjv6e"
   },
   "outputs": [],
   "source": [
    "def kinematic_tree_example():\n",
    "    plant = MultibodyPlant(time_step=0.0)\n",
    "    parser = Parser(plant)\n",
    "    ConfigureParser(parser)\n",
    "    parser.AddModelsFromUrl(\n",
    "        \"package://drake/manipulation/models/allegro_hand_description/sdf/allegro_hand_description_right.sdf\"\n",
    "    )\n",
    "    parser.AddModelsFromUrl(\n",
    "        \"package://drake/examples/manipulation_station/models/061_foam_brick.sdf\"\n",
    "    )\n",
    "    plant.Finalize()\n",
    "\n",
    "    # TODO(russt): Add floating base connections\n",
    "    # TODO(russt): Consider a more interactive javascript rendering?\n",
    "    display(\n",
    "        SVG(\n",
    "            pydot.graph_from_dot_data(plant.GetTopologyGraphvizString())[\n",
    "                0\n",
    "            ].create_svg()\n",
    "        )\n",
    "    )\n",
    "\n",
    "\n",
    "kinematic_tree_example()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [],
   "name": "Robotic Manipulation - Basic Pick and Place.ipynb",
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3.10.6 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  },
  "vscode": {
   "interpreter": {
    "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
